function add_to_cart(id) {
    $.ajax({
        type: "POST",
        url: webroot + '/users/add_cart/' + id,
        success: function(message) {
            $.jGrowl(message);
            if (message == 'Deal successfully added to your cart') {
                $('#' + id + '_add').hide();
                $('#' + id + '_remove').show();
            }
        }
    });
}
function remove_from_cart(id) {
    $.ajax({
        type: "POST",
        url: webroot + '/users/remove_cart/' + id,
        success: function(message) {
            $.jGrowl(message);
            if (message == 'Deal successfully removed from your cart') {
                $('#' + id + '_remove').hide();
                $('#' + id + '_add').show();
            }
        }
    });
}
$(document).ready(function() {
    $(".add_to_cart").click(function(event) {
        var id = event.target.id;
        id = id.substring(0, id.indexOf('_'));
        add_to_cart(id);
    });
    $(".remove_from_cart").click(function(event) {
        var id = event.target.id;
        id = id.substring(0, id.indexOf('_'));
        remove_from_cart(id);
    });
});
